<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改新人')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content" >
		<form class="form-horizontal m" id="form-people-edit" th:object="${people}">
			<input id="coupleId" name="coupleId" type="hidden" th:field="*{coupleId}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">新郎姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="coupleGroomname" id="coupleGroomname" required th:field="*{coupleGroomname}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">新郎姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="coupleBridename" id="coupleBridename" required th:field="*{coupleBridename}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">手机号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="couplePhone" id="couplePhone" required th:field="*{couplePhone}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">邮箱：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="coupleEmail" id="coupleEmail" required th:field="*{coupleEmail}">
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "user/people";
		
		$("#form-people-edit").validate({
			onkeyup: false,
			rules:{
				couplePhone:{
					remote: {
						url: prefix +"/checkPhone",
						type: "post",
						dataType: "json",
						data: {
							"couplePhone" : function() {
								return $.common.trim($("#couplePhone").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				coupleEmail:{
					remote: {
						url: prefix +"/checkEmail",
						type: "post",
						dataType: "json",
						data: {
							"coupleEmail" : function() {
								return $.common.trim($("#coupleEmail").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				postSort:{
					digits:true
				},
			},
			messages: {
				"couplePhone": {
					remote: "手机号已经存在"
				},
				"coupleEmail": {
					remote: "邮箱已经存在"
				}
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-people-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
